﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using CommunityToolkit.Mvvm.DependencyInjection;
using FanaticRock.Controls.Primitives;

namespace FanaticRock.Helpers
{
    ///<summary>窗口相关的工具类。</summary>
    public class WindowHelper
    {
        public static bool? Show(FrameworkElement frameworkElement)
        {
            var window = new FanaticRockWindow();
            window.Content = frameworkElement;

            window.Show();
            return true;
        }

        public static bool? Show<T>() where T : FrameworkElement
        {
            var frameworkElement = Ioc.Default.GetService<T>();
            if (frameworkElement == null)
                throw new  NullReferenceException($"WindowHelper.Show<T>: type {typeof(T)} 未注册");

            Show(frameworkElement);

            return true;
        }
    }
}
